﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>">	
	<!-- jsp文件头和头部 -->
	<link rel="stylesheet" href="static/css/font-awesome.min.css" />
	<!-- page specific plugin styles -->
	<!-- 下拉框-->
	<link rel="stylesheet" href="static/css/chosen.css" />
	<!-- ace styles -->
	<link rel="stylesheet" href="static/css/ace.min.css" />
	<link rel="stylesheet" href="static/css/ace-responsive.min.css" />
	<link rel="stylesheet" href="static/css/ace-skins.min.css" />
	<link rel="stylesheet" href="static/css/datepicker.css" /><!-- 日期框 -->
	<!-- 引入 -->
	<script src="static/1.9.1/jquery.min.js"></script>
	<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
	<!--引入弹窗组件start-->
	<script type="text/javascript" src="plugins/attention/zDialog/zDrag.js"></script>
	<script type="text/javascript" src="plugins/attention/zDialog/zDialog.js"></script>
	<script src="static/js/bootstrap.min.js"></script>
	<script src="static/js/ace-elements.min.js"></script>
	<script src="static/js/ace.min.js"></script>
	<!--引入弹窗组件end-->
	<script type="text/javascript" src="static/js/jquery.tips.js"></script>  
	<!-- 引入 -->
	<style type="text/css">
	@charset "utf-8";
	/* CSS Document */lwp
	body, td { font-size:12px Verdana; color:808284;}
	a:link { color:cccccc; text-decoration:none; cursor:pointer}
	a:active { color:cccccc; text-decoration:none; }
	a:visited { color:cccccc; text-decoration:none; }
	a:hover { color:ff0000; text-decoration:underline; }
	body, td, th { font-size: 12px;}
	img{ border:0}
	
	#content{ padding:0; margin:0 auto; width:1470px}
	.D_table{font-size:12px;color:808284; background-color:#b7c9f2; border:0;}
	.D_bt{ background:url(<%=basePath%>static/calendar/dh_bj.png) repeat-x;height:36px; font-size:14px; color: #CCFF33; text-align:center;font-weight:bold}
	
	.D_bt a:link,.D_bt a:visited{text-decoration:none;color:#ffffff}
	.D_bt a:hover{text-decoration:none;color: #FFFF00}
	
	.week{ background-color:#e6edfd; text-align:center; height:20px; font-weight:bold}
	.week b{ color:#FF0000;}
	.week em{ font-style:normal; color:#00CC00}
	
	.today{ height:110px; padding:0px; margin:0px; vertical-align:top; background:url(<%=basePath%>static/calendar/currentToday.png) repeat-x bottom;}
	.dd{height:110px; padding:0px; margin:0px; vertical-align:top; background-position:bottom}
	.dd1{height:110px; padding:0px; margin:0px; vertical-align:top; background-position:bottom}
	.red{ color:#FF0000;}
	.green{ color:#00CC00;}
	.db{height:20px; border-bottom:1px solid #DDEEFF;background: #F1F2F2;margin:0px;}
	.kb{ background:url(<%=basePath%>static/calendar/kongban.png) repeat-x bottom;}
	
	.yl{float:left; width:20px;padding:3px 0 0 0!important;padding:2px 0 0 0}
	.nl{float:right;width:40px;padding:2px 0 0 0!important;padding:3px 0 0 0}
	</style>
	</head>
<body>
<script type="text/javascript">
var myDate = new Date();
var myYear = myDate.getFullYear();
var myMonth = myDate.getMonth()+1;
var myDay = myDate.getDate();

//------------------------用来计算阴历---START---------------------
function CnMonthofDate(DateGL){
var CnMonthStr=new Array("零","正","二","三","四","五","六","七","八","九","十","冬","腊");
var Month;
Month = parseInt(CnDateofDate(DateGL)/100);
if (Month < 0){return CnMonthStr[-Month] + "月";}
else{return CnMonthStr[Month] + "月";}
}

function CnDayofDate(DateGL){
var CnDayStr=new Array("零",
    "初一", "初二", "初三", "初四", "初五",
    "初六", "初七", "初八", "初九", "初十",
    "十一", "十二", "十三", "十四", "十五",
    "十六", "十七", "十八", "十九", "二十",
    "廿一", "廿二", "廿三", "廿四", "廿五",
    "廿六", "廿七", "廿八", "廿九", "三十");
var Day;
Day = (Math.abs(CnDateofDate(DateGL)))%100;
return CnDayStr[Day];
}

function DaysNumberofDate(DateGL){
return parseInt((Date.parse(DateGL)-Date.parse(DateGL.getFullYear()+"/1/1"))/86400000)+1;
}

function CnDateofDate(DateGL){
var CnData=new Array(
0x16,0x2a,0xda,0x00,0x83,0x49,0xb6,0x05,0x0e,0x64,0xbb,0x00,0x19,0xb2,0x5b,0x00,
0x87,0x6a,0x57,0x04,0x12,0x75,0x2b,0x00,0x1d,0xb6,0x95,0x00,0x8a,0xad,0x55,0x02,
0x15,0x55,0xaa,0x00,0x82,0x55,0x6c,0x07,0x0d,0xc9,0x76,0x00,0x17,0x64,0xb7,0x00,
0x86,0xe4,0xae,0x05,0x11,0xea,0x56,0x00,0x1b,0x6d,0x2a,0x00,0x88,0x5a,0xaa,0x04,
0x14,0xad,0x55,0x00,0x81,0xaa,0xd5,0x09,0x0b,0x52,0xea,0x00,0x16,0xa9,0x6d,0x00,
0x84,0xa9,0x5d,0x06,0x0f,0xd4,0xae,0x00,0x1a,0xea,0x4d,0x00,0x87,0xba,0x55,0x04
);
var CnMonth=new Array();
var CnMonthDays=new Array();
var CnBeginDay;
var LeapMonth;
var Bytes=new Array();
var I;
var CnMonthData;
var DaysCount;
var CnDaysCount;
var ResultMonth;
var ResultDay;
var yyyy=DateGL.getFullYear();
var mm=DateGL.getMonth()+1;
var dd=DateGL.getDate();
if(yyyy<100) yyyy+=1900;

Bytes[0] = CnData[(yyyy - 1997) * 4];
Bytes[1] = CnData[(yyyy - 1997) * 4 + 1];
Bytes[2] = CnData[(yyyy - 1997) * 4 + 2];
Bytes[3] = CnData[(yyyy - 1997) * 4 + 3];
if ((Bytes[0] & 0x80) != 0) {CnMonth[0] = 12;}
else {CnMonth[0] = 11;}
CnBeginDay = (Bytes[0] & 0x7f);
CnMonthData = Bytes[1];
CnMonthData = CnMonthData << 8;
CnMonthData = CnMonthData | Bytes[2];
LeapMonth = Bytes[3];
for (I=15;I>=0;I--){
    CnMonthDays[15 - I] = 29;
    if (((1 << I) & CnMonthData) != 0 ){
      CnMonthDays[15 - I]++;}
    if (CnMonth[15 - I] == LeapMonth ){
      CnMonth[15 - I + 1] = - LeapMonth;}
    else{
      if (CnMonth[15 - I] < 0 ){CnMonth[15 - I + 1] = - CnMonth[15 - I] + 1;}
      else {CnMonth[15 - I + 1] = CnMonth[15 - I] + 1;}
      if (CnMonth[15 - I + 1] > 12 ){ CnMonth[15 - I + 1] = 1;}
    }
}
DaysCount = DaysNumberofDate(DateGL) - 1;
if (DaysCount <= (CnMonthDays[0] - CnBeginDay)){
    if ((yyyy > 1901) && (CnDateofDate(new Date((yyyy - 1)+"/12/31")) < 0)){
      ResultMonth = - CnMonth[0];}
    else {ResultMonth = CnMonth[0];}
    ResultDay = CnBeginDay + DaysCount;
}
else{
    CnDaysCount = CnMonthDays[0] - CnBeginDay;
    I = 1;
    while ((CnDaysCount < DaysCount) && (CnDaysCount + CnMonthDays[I] < DaysCount)){
      CnDaysCount+= CnMonthDays[I];
      I++;
    }
    ResultMonth = CnMonth[I];
    ResultDay = DaysCount - CnDaysCount;
}
if (ResultMonth > 0){
    return ResultMonth * 100 + ResultDay;}
else{return ResultMonth * 100 - ResultDay;}
}


function CnDateofDateStr(DateGL){//此计算方法的开口.只要调用些方法传进Date对像就OK!!!
 return  CnDayofDate(DateGL);
}

//------------------------用来计算阴历---END---------------------
  function  montharr(m0,   m1,   m2,   m3,   m4,   m5,   m6,   m7,   m8,   m9,   m10,   m11){   //分别代表12个月
	  this[0]=m0;//画日历的外观   
	  this[1]=m1;   
	  this[2]=m2;   
	  this[3]=m3;   
	  this[4]=m4;   
	  this[5]=m5;   
	  this[6]=m6;   
	  this[7]=m7;   
	  this[8]=m8;   
	  this[9]=m9;   
	  this[10]=m10;   
	  this[11]=m11;
	}   
  function calendar(today){
	  var  monthname=new Array("一月",   "二月",   "三月",   "四月",   "五月",   "六月",   "七月",   "八月",   "九月",   "十月",   "十一月",   "十二月");   
	  var  thisDay;   
	  var  monthDays=new montharr(31,   28,   31,   30,   31,  30,   31,   31,  30, 31,   30,   31);   //每个月的总天数
	  year=today.getYear();   
	  thisDay=new Date().getDate();   //取到当前日期

	  if (((year %  4==0) && (year % 100 !=  0)) || (year % 400==0))//闰年   
	  monthDays[1]=29; 
		
	  nDays=monthDays[today.getMonth()];   //得到当月的总天数

	  firstDay=today;   
	  firstDay.setDate(1);   //  设置当前月的第一天


	  testMe=firstDay.getDate(); 
	 
	  if  (testMe==2)   
	  firstDay.setDate(0);  
	  
	  startDay=firstDay.getDay();  //返回当前是星期几0-6
	  
	  var cYear=today.getFullYear();
	  var cMonth=today.getMonth()+1;
	  if(cMonth<10)
		cMonth=0+""+cMonth;


	  //用来比较是整是当前月
	  var cuDate=new Date();
	  var cuValue=cuDate.getFullYear()+""+cuDate.getMonth()+1;
	  var prValue=today.getFullYear()+""+today.getMonth()+1;

		
	  content=" <div id='content'  scroll=no> ";

	  content+="<table  id=ta class='D_table' cellspacing=1   cellpadding=0 onmouseover= voerData(event) onmouseout=outData(event) >";   
	  content+="<tr><td  colspan=7 class='D_bt'>";   
	  content+="&nbsp;<A title=上一年 href='javascript:PreYear()'><IMG src='<%=basePath%>static/calendar/main_2.gif'></A>&nbsp;&nbsp;";  
		
	  content+="<A title=上一月 href='javascript:PreMonth()'>上一月</A>&nbsp;&nbsp;&nbsp;";   
	  
	  content+="<span id='cyear'>"+cYear+"</span>年<span id='cmonth'>"+cMonth+"</span>月&nbsp;&nbsp;&nbsp;"; 

	  content+="<A title=下一月 href='javascript:NextMonth()'>下一月</A>&nbsp;&nbsp;&nbsp;"; 

	  content+="<A title=下一年 href='javascript:NextYear()'><IMG src='<%=basePath%>static/calendar/main_1.gif'></A> &nbsp;&nbsp;&nbsp;"; 

      content+="<A href='javascript:NowMonth()'><b>本月</b></A> "; 

	  content+="<tr class='week'><td width='210px'><b>星期日</b><td width='210px'>星期一<td width='210px'>星期二<td width='210px'>星期三<td width='210px'>星期四<td width='210px'>星期五<td width='210px'><em>星期六</em>";   
	  content+="<tr>";   
	  column=0; 
	 
	  for(i=0; i<startDay;i++){  //画出前面空白的日期
		  content+="<td class='kb'>";    
		  column++;
	  }   
	 
	  for(i=1;i<=nDays;i++){//画出主体部分的日期
	  	var nowDate = cYear+"-"+cMonth+"-";
	    if(i<10){
	  		nowDate += "0"+i;
	  	}else{
	  		nowDate += i;
	  	}
		var tday=today;
		tday.setDate(i);
		current=tday.getDay();//当前是本周的第几天
		if (cuValue==prValue&&i==thisDay)//今天 
		{
			if(current==0)
				content+="<td class='today'>"; 
			else if(current==6)
				content+="<td class='today'>"; 
			else
				content+="<td class='today'>"; 
		}
		else
		{
			if(current==0)
				content+="<td id='d"+i+"' target=1 background='<%=basePath%>static/calendar/putong.png' class='dd red'>"; 
			else if(current==6)
				content+="<td id='d"+i+"' target=1 background='<%=basePath%>static/calendar/putong.png' class='dd green'>"; 
			else
				content+="<td id='d"+i+"' target=1 background='<%=basePath%>static/calendar/putong.png' class='dd1'>"; 
		}
		var cal=CnDateofDateStr(new Date(today.getFullYear(),today.getMonth(),i));//阴历在此计算
		content+="<div class='db'>";
		content+="<span class='yl'>"+i+"</span>";
		if (cuValue==prValue&&i==thisDay)//今天
			content+="<span class='nl'>"+cal+"<a href='javascript:addSchedule("+thisDay+");' title='添加新日程'><img src='<%=basePath%>static/calendar/audit.gif' align='absmiddle'></a></span>";
		else
			content+="<span id='md"+i+"'  class='nl'>"+cal+"</span>";

		content+="</div>"
		
		var map =  '${dateMap}';
		map = eval("(" + map + ")");
		$.each(map,function(name,value) {
			if(name == nowDate){
				var dateList = eval(value);
				for(var k=0;k<dateList.length;k++){
					var schedule_title = dateList[k].schedule_title;
					var id = dateList[k].schedule_id;
					var title = dateList[k].title;
					content+="<a href='javascript:editSchedule(\""+id+"\");' style='text-decoration:none;' title='"+title+"'>"+schedule_title+"</a><br/>";
				}				
			}
		});
		
	    column++;   
	    if(column==7){//画下一行
			content+="<tr>";   
			column=0;
		 
	    }
	    
		}
		if((42-startDay-nDays)%7!=0)
			if (column<7)//画出结束的空白日期
			{	
			   for (j=1;j<(7-column+1);j++){   
				   content+="<td class='kb' id=d"+i+">";    
			   }
			}
		  content+="</table>";   
	}//画日历外观结束   

 function NowMonth() {
	calendar(new Date());
	document.body.innerHTML=content;
  }
  //上一月
  function PreMonth() {
	var objY=document.getElementById('cyear');
	var objM=document.getElementById('cmonth');
	var year=objY.innerHTML;
	var month=objM.innerHTML;
	var y = new Number(year);
    var m = new Number(month);
    myYear = y-0;
	myMonth = m-1;
	calendar(new Date(y, m-2, 1));
	document.body.innerHTML=content;
  }
  //下一月
   function NextMonth() {
	var objY=document.getElementById('cyear');
	var objM=document.getElementById('cmonth');
	var year=objY.innerHTML;
	var month=objM.innerHTML;
	var y = new Number(year);
    var m = new Number(month);
    myYear = y-0;
	myMonth = m+1;
	calendar(new Date(y, m,1));
	document.body.innerHTML=content;
  }
  //上一年
   function PreYear() {
   	var objY=document.getElementById('cyear');
	var objM=document.getElementById('cmonth');
	var year=objY.innerHTML;
	var month=objM.innerHTML;
	var y = new Number(year);
    var m = new Number(month);
    myYear = y-1;
	myMonth = m-0;
	calendar(new Date(y-1,m-1,1));
	document.body.innerHTML=content;
  }
  //下一年
   function NextYear() {
    var objY=document.getElementById('cyear');
	var objM=document.getElementById('cmonth');
	var year=objY.innerHTML;
	var month=objM.innerHTML;
	var y = new Number(year);
    var m = new Number(month);
    myYear = y+1;
	myMonth = m-0;
	calendar(new Date(y+1, m-1,1));
	document.body.innerHTML=content;
  }
	
   function changeContent()
   {
    calendar(new Date());  
	document.body.innerHTML=content;
   }

   var mid=null;
   function voerData(e)
   {
		var node=e.target?e.target: window.event.srcElement;
		
		if (node.tagName=='DIV')
			node=node.parentNode;
		if (node.tagName=='SPAN')
			node=node.parentNode.parentNode;
		if (node.tagName=='IMG')
			node=node.parentNode.parentNode.parentNode;

		if(node.tagName!='TD')return;

		var target = node.getAttribute('target');
		if(target==1)
		{
			var nid=node.getAttribute('id');
			
			if(mid!=null&&mid!=nid)
			{
				var oldNode =document.getElementById(mid);
				oldNode.setAttribute('background','<%=basePath%>static/calendar/putong.png');
				var changeTd =document.getElementById('m'+mid);
				changeTd.innerHTML=changeTd.innerHTML.substring(0,2);

				node.setAttribute('background','<%=basePath%>static/calendar/mouseOver.png');
				var changeTd =document.getElementById('m'+nid);
				if(changeTd.innerHTML.length==2)
				{
					changeTd.innerHTML=changeTd.innerHTML+"<a href='javascript:addSchedule("+nid+");' title='添加新日程'><img src='<%=basePath%>static/calendar/audit.gif' align='absmiddle'></a>";
				}
			}else
			{
				node.setAttribute('background','<%=basePath%>static/calendar/mouseOver.png');
				var changeTd =document.getElementById('m'+nid);
				if(changeTd.innerHTML.length==2)
				{
					changeTd.innerHTML=changeTd.innerHTML+"<a href='javascript:addSchedule("+nid+");' title='添加新日程'><img src='<%=basePath%>static/calendar/audit.gif' align='absmiddle'></a>";
				}
			}
		}
   }
   function outData(e)
   {
		var node=e.target?e.target: window.event.srcElement;
		if (node.tagName=='DIV')
			node=node.parentNode;
		if (node.tagName=='SPAN')
			node=node.parentNode.parentNode;
		if (node.tagName=='IMG')
			node=node.parentNode.parentNode.parentNode;
		if(node.tagName!='TD')return;

		var target = node.getAttribute('target');
		if(target==1)
		{
			mid=node.getAttribute('id');
		}

   }
</script>		
<script type="text/javascript">
	$(document).ready(function(){
	    changeContent();
	});
		top.hangge();
		//新增组
		function addSchedule(day){
			var sdate = 1;
			var date = new Date();
			//获取日期
			if(isNaN(day)){
				var month = date.getMonth()+1;
				day = day.getAttribute('id')
				sdate = myYear +"-"+ myMonth +"-"+ day.substr(1);
			}else{
				var month = date.getMonth()+1;
				sdate = myYear +"-"+ myMonth +"-"+ day;
			}
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="新增日程";
			 diag.URL = '<%=basePath%>sysschedule/goAdd.do?schedule_date='+sdate;
			 diag.Width = 510;
			 diag.Height = 550;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					top.jzts();
					setTimeout("self.location.reload()",100);
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//修改
		function editSchedule(schedule_id){
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="编辑";
			 diag.URL = '<%=basePath%>sysschedule/goEdit.do?schedule_id='+schedule_id;
			 diag.Width = 510;
			 diag.Height = 550;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
					top.jzts();
					setTimeout("self.location.reload()",100);
				}
				diag.close();
			 };
			 diag.show();
		}
		</script>
	</body>
</html>

